<script setup lang="ts" name="columnMsg">
import useColumnMsg from '@/components/index/card/hooks/columnMsg'
const { listData, isSelected, clicked } = useColumnMsg()
</script>

<template>
  <ul id="clumns">
    <li
      v-for="item in listData"
      :key="item.id"
      :class="{ active: isSelected === item.id }"
      @click="clicked(item)"
    >
      <div>
        <img class="clumnsImg" :src="item.img" alt="" />
      </div>
      <div>
        <p class="top">
          <b>{{ item.name }}</b>
        </p>
        <p class="center">
          <StarFilled class="svg" />
          <span>{{ item.followed }}</span>
          <Document class="svg" />
          <span>{{ item.total }}</span>
        </p>
        <p class="bottom">
          <b>{{ 'by：' + item.by }}</b>
        </p>
      </div>
    </li>
  </ul>
</template>

<style scoped lang="less">
.active {
  outline: 2px solid var(--color3);
  color: #fff;
}
.clumnsImg {
  display: inline-block;
  vertical-align: middle;
  width: 56px;
  height: 56px;
  margin: 8px;
  border-radius: var(--radius);
}
.svg {
  width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-block;
  vertical-align: middle;
}
#clumns {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 72px;
  gap: 10px;
  > li:hover {
    cursor: pointer;
    outline: 2px solid var(--color3);
    color: #fff;
  }

  > li {
    border-radius: var(--radius);
    overflow: hidden;
    background-color: var(--color2);
    display: grid;
    grid-template-columns: 72px 1fr;
    > div {
      > p {
        padding: 2px 0;
        > span {
          display: inline-block;
          vertical-align: middle;
        }
      }
    }
    > div:nth-child(2) {
      box-sizing: border-box;
      > .top {
        height: 20px;
        line-height: 20px;
        padding-left: 4px;
        > b {
          display: block;
          max-width: 200px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }
      > .center {
        height: 23px;
        box-sizing: border-box;
      }
      > .bottom {
        height: 20px;

        text-align: end;
        padding-right: 20px;
        line-height: 20px;
        > b {
          font-weight: normal;
          max-width: 120px;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }
    }
  }
}
</style>
